<?php
/**
 * Created by PhpStorm
 * User: ZhouFurong
 * Date: 2020/12/8
 * Time: 14:27
 */

/**
 * @param $number
 * @return bool
 * @throws Exception
 * @author ZhouFurong
 * @date 2020/12/8
 */
//create function with an exception
function checkNum($number)
{
    if ($number > 1) {
        throw new Exception("Value must be 1 or below");
    }
    return true;
}

try{
    //触发一个异常
    checkNum(10);
}catch (Exception $e){
    echo 'Message: '.$e->getMessage();
}
